package 匿名内部类开发使用;

public class JuppingDemo {
    public static void main(String[] args) {
        JumppingOperator jo=new JumppingOperator();
        //创建猫类子类对象
        Jumpping j=new Cat();
        jo.method(j);
        //创建狗类子类对象
        Jumpping j2=new Dog();
        jo.method(j2);
        System.out.println("--------");

        //本质是继承了该类，实现了该接口的子类的匿名对象
        jo.method(new Jumpping() {
            @Override
            public void jump() {
                System.out.println("猫跳高");
            }
        });
        jo.method(new Jumpping() {
            @Override
            public void jump() {
                System.out.println("狗跳高");
            }
        });
    }
}
